using System;

namespace IBNet
{
   /// <summary>
   /// Portfolio Event Arguments
   /// </summary>
   public class PortfolioEventArgs : EventArgs
   {
      private readonly Contract contract;
      private readonly int position;
      private readonly decimal marketPrice;
      private readonly decimal marketValue;
      private readonly decimal averageCost;
      private readonly decimal unrealizedPnl;
      private readonly decimal realizedPnl;
      private readonly string accountName;

      /// <summary>
      /// Creates a new PortfolioEventArgs.
      /// </summary>
      /// <param name="contract">The Contract.</param>
      /// <param name="position">The position in the Contract.</param>
      /// <param name="marketPrice">The unit price of the Contract.</param>
      /// <param name="marketValue">The total market value of the position in the Contract.</param>
      /// <param name="averageCost">The average cost per share of this position.</param>
      /// <param name="unrealizedPnl">The unrealized profit or loss of this position.</param>
      /// <param name="realizedPnl">The realized profit or loss of this position.</param>
      /// <param name="accountName">The account name this PortfolioEventArgs applies to. 
      /// Useful for Financial Advisor sub-account messages.</param>
      public PortfolioEventArgs(Contract contract, int position, decimal marketPrice,
         decimal marketValue, decimal averageCost, decimal unrealizedPnl, 
         decimal realizedPnl, string accountName)
      {
         this.contract = contract;
         this.accountName = accountName;
         this.realizedPnl = realizedPnl;
         this.unrealizedPnl = unrealizedPnl;
         this.averageCost = averageCost;
         this.marketValue = marketValue;
         this.marketPrice = marketPrice;
         this.position = position;
      }

      /// <summary>
      /// Gets the Contract this PortfolioEventArgs is for.
      /// </summary>
      public Contract Contract
      {
         get { return contract; }
      }

      /// <summary>
      /// Gets the position in the Contract.
      /// </summary>
      public int Position
      {
         get { return position; }
      }

      /// <summary>
      /// Gets the market price of the Contract.
      /// </summary>
      public decimal MarketPrice
      {
         get { return marketPrice; }
      }

      /// <summary>
      /// Gets the market value of this position.
      /// </summary>
      public decimal MarketValue
      {
         get { return marketValue; }
      }

      /// <summary>
      /// Gets the average cost per share of this position.
      /// </summary>
      public decimal AverageCost
      {
         get { return averageCost; }
      }

      /// <summary>
      /// Gets the unrealized profit or loss of this position.
      /// </summary>
      public decimal UnrealizedPnl
      {
         get { return unrealizedPnl; }
      }

      /// <summary>
      /// Gets the realized profit or loss of this position.
      /// </summary>
      public decimal RealizedPnl
      {
         get { return realizedPnl; }
      }

      /// <summary>
      /// Gets the account name this PortfolioEventArgs applies to.
      /// </summary>
      public string AccountName
      {
         get { return accountName; }
      }
   }
}